<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class ServeProject extends Authenticatable
{
    use Notifiable;
	protected $table = 'serve_projects';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];

    // 获取可用的服务
	public static function getAllServeId(){
		$ServeArr = DB::table('serve_projects')
			->select('serveType','serveName')
			->get()
			->toArray();
		if(!$ServeArr){
			return array();
		}
		return $ServeArr;
	}

	// 根据id或者名称
	public static function getNameById($id){
		$name = '';
		$name = ServeProject::where('id',$id)->pluck('serveName');
		if($name){
			$name = $name[0];
		}
		return $name;
	}

	// 获取服务项目下的订单情况
	public static function getServeProjectOrder($sid){
		$serveProjectOrder = DB::table('serve_projects')
			->leftjoin('order', 'serve_projects.id', '=', 'order.server_id')
			->where('serve_projects.id',$sid)
			->select('order.*')
			->get()
			->toArray();
		if(!$serveProjectOrder){
			return array();
		}
		return $serveProjectOrder;
	}




}
